package com.zhuss.controller.core;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.zhuss.bean.bo.core.permission.CreatePermissionBo;
import com.zhuss.bean.bo.core.permission.DeletePermissionBo;
import com.zhuss.bean.bo.core.permission.PermissionResourceBindBo;
import com.zhuss.bean.bo.core.permission.PermissionRoleBindBo;
import com.zhuss.bean.bo.core.permission.UpdatePermissionBo;
import com.zhuss.common.BaseController;
import com.zhuss.common.OperateService;
import com.zhuss.core.permission.PermissionOperateServiceExt;
import com.zhuss.exception.AabException;


/**
 * 权限点操作 controller
 * @Author zhushanshuo
   @Date 2019-12-28 21:36
 *
 */
  
 
@RestController
@RequestMapping("/permission")
public class PermissionOperateController extends BaseController {
	
	@Autowired
	@Qualifier("permissionOperateService")
	private OperateService<Object, Object> permissionOperateService;
	
	@Autowired
	@Qualifier("permissionOperateServiceExt")
	private PermissionOperateServiceExt permissionOperateServiceExt;
	
	/**
	 * 创建
	 * @param bo
	 * @throws AabException
	 */
	@ResponseBody
    @PostMapping("/create")
    public Long create(@RequestBody CreatePermissionBo bo) throws AabException {
		
		return Long.valueOf(permissionOperateService.create(bo) + "");
    }
	
	/**
	 * 修改
	 * @param bo
	 * @throws AabException
	 */
	@ResponseBody
    @PostMapping("/update")
    public void update(@RequestBody UpdatePermissionBo bo) throws AabException {
		
		permissionOperateService.update(bo);
    }
	
	/**
	 * 删除
	 * @param bo
	 * @throws AabException
	 */
	@ResponseBody
    @PostMapping("/delete")
    public void delete(@RequestBody DeletePermissionBo bo) throws AabException {
		
		permissionOperateService.delete(bo);
    }
	
	/**
	 * 给权限点绑定菜单资源
	 * @param bo
	 * @throws AabException
	 */
	@ResponseBody
    @PostMapping("/permissionResourceBind")
    public void permissionResourceBind(@RequestBody PermissionResourceBindBo bo) throws AabException {
		
		permissionOperateServiceExt.permissionResourceBind(bo);
    }
	
	
	/**
	 * 给权限点绑定角色
	 * @param bo
	 * @throws AabException
	 */
	@ResponseBody
    @PostMapping("/permissionRoleBind")
    public void permissionRoleBind(@RequestBody PermissionRoleBindBo bo) throws AabException {
		
		permissionOperateServiceExt.permissionRoleBind(bo);
    }



	
}
